
const path = require('path');
module.exports = {
    lintOnSave: false,
    chainWebpack: config => {
        const types = ['vue-modules', 'vue', 'normal-modules', 'normal'];
        types.forEach(type => addStyleResource(config.module.rule('less').oneOf(type)))
    },
    devServer: {
        //跨域
        proxy: {
            '/api': {
                target: 'http://icve.com.cn', //路径指向本地主机地址及端口号
                changOrigin: true, //准许跨域
                //路径重写
                pathRewrite: {
                    //重写路径，当我们在浏览器中看到请求的地址为：
                    //http://localhost:8080/api/frontend/experts/getlist 时
                    //实际上访问的地址是：
                    //http://localhost:8081/dong-guan-project/tp6-dgjx/public/index.php/frontend/experts/getlist
                    //因为重写了 /api
                    '^/api': '' //路径转发代理
                }
            }
        }
    }
    
};

//配置全局less文件
function addStyleResource(rule) {
    rule.use('style-resource')
        .loader('style-resources-loader')
        .options({
            patterns: [path.resolve(__dirname, "./src/assets/css/_theme1.less")]
        });
}

